home *** CD-ROM | disk | FTP | other *** search
/ 9-Digit Zip Code Directory / 9-Digit Zip Code Directory (American Business Information) (ABIZIP-12).ISO / z4src.zip / BSASSERT.C < prev    next >
C/C++ Source or Header  |  1995-07-30  |  3KB  |  113 lines

  1. //----------------------------------------------------------------------------
  2. //                            MODULE DESCRIPTION
  3. //
  4. //  Module:    bsassert.c
  5. //   Title:    Base library
  6. //  Notice:    John M. Weeder
  7. //                 Copyright (c) 1993. All rights reserved.
  8. //             This module contains proprietary information and should be 
  9. //                treated as confidential.
  10. //
  11. //----------------------------------------------------------------------------
  12. //                           MAINTENANCE HISTORY
  13. //
  14. // $Workfile$
  15. // $Revision$
  16. //   $Author$
  17. //     $Date$
  18. //      $Log$    
  19. //
  20. //----------------------------------------------------------------------------
  21. //                             MODULE NARRATIVE
  22. //
  23. //
  24. //    This module contains code to handle assertions.
  25. //
  26. //    The code in this module should be written entirely in C. 
  27. //    Do not use any C++ constructs.
  28. //
  29. //    This module is portable to:
  30. //        DOS 3.X+
  31. //        MS Windows 3.X+
  32. //        OS/2 2.X+
  33. //        OS/2 2.0 PM
  34. //        SCO UNIX.
  35. //
  36. //    The following compilers are supported:
  37. //        MSC 6.0A
  38. //        MSC/C++ 7.0
  39. //        Borland C++ 3.1 for DOS
  40. //        Borland C++ 1.0 for OS/2 2.X
  41. //        SCO UNIX cc
  42. //
  43. //----------------------------------------------------------------------------
  44. #include <bs.h>
  45.  
  46.  
  47. //----------------------------------------------------------------------------
  48. //   Description:    Handle an assertion
  49. //    Parameters:    pcsz                Assertion expression.
  50. //       Returns:    FALSE
  51. //                        This function normally exits!
  52. //----------------------------------------------------------------------------
  53. BOOL FN_E Assert_Debug(PCSZ pcsz)
  54. {
  55.     FILE *fileLog = fopen("assert.log", "a+t");
  56.     CHAR szContext[IOBUF_SIZE];
  57.  
  58.     if (fileLog != NULL)
  59.         {
  60.         DebugContext(szContext, TRUE);
  61.         fprintf(fileLog,
  62.             "%s"
  63.             "Assertion Failed!\n"
  64.             "%s\n",
  65.             szContext, pcsz);
  66.  
  67.         fclose(fileLog);
  68.         }
  69.     DebugContext(szContext, FALSE);
  70. #if OS_WINDOWS
  71.     strcat(szContext, pcsz);
  72.     MessageBox(NULL, szContext, "ASSERTION !", MB_ICONEXCLAMATION|MB_OK|MB_TASKMODAL);
  73. #elif OS_PM
  74.  
  75. #else
  76.     fprintf(stderr,
  77.         "\n"
  78.         "%s"
  79.         "Assertion Failed!\n"
  80.         "%s\n"
  81.         "\n",
  82.         szContext, pcsz);
  83. #endif
  84.  
  85. #if OS_DOS && COMPILER_BORLAND
  86.     CtrlCTerminate();
  87.     PrintScreenTerminate();
  88.     CritErrTerminate();
  89. #endif
  90.  
  91.     _exit(99);
  92.     return FALSE;
  93. }
  94.  
  95.  
  96. //----------------------------------------------------------------------------
  97. //   Description:    Run standard test suite
  98. //    Parameters:    sTest        Test to run.
  99. //                                        0        Run all default tests (except).
  100. //                                        1        Assertion
  101. //       Returns:    TRUE if successful.
  102. //----------------------------------------------------------------------------
  103. #if COMPILE_TEST
  104. BOOL FN AssertTest(SHORT sTest)
  105. {
  106.     Assert(sTest == 0);
  107.     return TRUE;
  108. }
  109. #endif
  110. //----------------------------------------------------------------------------
  111. //------------------------------- End of File --------------------------------
  112. //----------------------------------------------------------------------------
  113.